using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XFGameFramework;
using UnityEngine.UI;
public class HomePanel : Panel
{
    #region 字段
    [SerializeField] private Button btn_fight;
    [SerializeField] private Image img_hp_bg;
    [SerializeField] private Image img_hp_value;
    [SerializeField] private Image img_hp_icon;
    [SerializeField] private Image img_strength_bg;
    [SerializeField] private Image img_strength_value;
    [SerializeField] private Image img_strengh_icon;
    [SerializeField] private Text text_Date;
    [SerializeField] private Text text_period;
    [SerializeField] private Text text_Clock;
    [SerializeField] private Text text_remaining_time;
    [SerializeField] private Button btn_back;

    private void Reset()
    {
        img_hp_bg = transform.Find("状态栏/img_hp_bg").GetComponent<Image>();
        img_hp_value = transform.Find("状态栏/img_hp_bg/img_hp_value").GetComponent<Image>();
        img_hp_icon = transform.Find("状态栏/img_hp_bg/img_hp_icon").GetComponent<Image>();
        img_strength_bg = transform.Find("状态栏/img_strength_bg").GetComponent<Image>();
        img_strength_value = transform.Find("状态栏/img_strength_bg/img_strength_value").GetComponent<Image>();
        img_strengh_icon = transform.Find("状态栏/img_strength_bg/img_strengh_icon").GetComponent<Image>();
        text_Date = transform.Find("时间/text_Date").GetComponent<Text>();
        text_period = transform.Find("时间/text_时段").GetComponent<Text>();
        text_Clock = transform.Find("时间/text_Clock").GetComponent<Text>();
        text_remaining_time = transform.Find("时间/text_剩余时间").GetComponent<Text>();
        btn_back = transform.Find("btn_back").GetComponent<Button>();
    }
    #endregion

    private GameSaveController gameSaveController => Module.LoadController<GameSaveController>();
    private TimeController timeController => Module.LoadController<TimeController>();
    private GameController gameController => Module.LoadController<GameController>();
    #region UI监听事件
    public void OnBtnBackClick()
    {
        gameController.SetGameState(GameState.Start);
    }

    public void onBtnFightClick()
    {
        gameController.SetGameState(GameState.Game_Run);
    }
    #endregion
    #region 重载方法
    public override void OnLoaded(params object[] param)
    {
        base.OnLoaded(param);
        UpdateUI();
    }
    #endregion
    #region 方法
    private void UpdateUI()
    {
        // TimeModel timemodel = gameSaveController.GetTimeModel(gameController.GetCurrentArchiveIndex());
        // print(timeController.Days);
        // text_Date.text = "第" + timeController.Days + "天";
        // text_period.text = GetPeriodstring(timeController.CurrentPeriod);
        // text_Clock.text = timeController.Hours + ":" + timeController.Minutes;
        // text_remaining_time.text = timeController.RemainingTime + "小时";
    }
    private string GetPeriodstring(Period period)
    {
        switch (period)
        {
            case Period.Morning:
                return "早上";
            case Period.Afternoon:
                return "下午";
            case Period.Evening:
                return "晚上";
            case Period.Night:
                return "夜晚";
            default:
                return "未知";
        }
    }
    #endregion
}
